﻿@using System.Linq
@model FrogFoot.Areas.Admin.Models.GriddingViewModel

<table class="prodGridTable">
    <thead>
        <tr>
            <td style="border: none;"></td>
            @foreach (var prod in Model.ISPProducts)
            {
                <th class="rotate"><div><span>@prod.ProductName @prod.LineSpeed @(prod.IsCapped ? "capped" : "uncapped") @prod.MonthlyCost</span></div></th>
            }
        </tr>
    </thead>
    <tbody>
        @foreach (var loc in Model.Locations)
        {
            <tr>
                <td class="name">
                    <span>@loc.Name</span>
                    @if (loc.Estates.Any())
                {
                        <input data-locid="@loc.LocationId" class="estateBtn btn btn-default" type="button" value="Estates" />
                    }
                </td>

                @foreach (var prod in Model.ISPProducts)
                {
                    <td>
                        @{
                            var ispProdLoc = loc.ISPLocationProducts.FirstOrDefault(x => x.ISPProductId == prod.ISPProductId);
                        }
                        @if (ispProdLoc == null)
                    {
                            <div class="gridBlock" data-prodgridid="" data-locationid="@loc.LocationId" data-prodid="@prod.ISPProductId">
                            </div>
                        }
                        else
                        {
                            <div class="gridBlock glyphicon glyphicon-ok" data-prodgridid="@ispProdLoc.ISPLocationProductId" data-locationid="@loc.LocationId" data-prodid="@prod.ISPProductId">
                            </div>
                        }
                    </td>
                            }
            </tr>
                            }
    </tbody>
</table>